We were having a discussion about constants and an interesting issue came up. I’ve always known that when you use a constant it gets interpreted as a literal when your code compiles, but I never made the connection that this is true of referenced constants as well. This creates a bit of an issue when you have a common assembly with constants – if you update the constants in your common assembly and then deploy just the common assembly, the assemblies that reference that common assembly will not get the “updated” constant values because it was, in essence, converted into a literal and compiled directly into the assembly. As such, it may make more sense to use static read-only variables instead of constants if they are referenced from a common assembly.
Of course, if you deploy everything all together you won’t encounter this issue because all the assemblies will be compiled with the new constants.
Load comments